package com.seckillpro.seckill_pro.config;

import com.rabbitmq.client.impl.AMQImpl;
import net.sf.jsqlparser.statement.select.Top;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Package: com.seckillpro.seckill_pro.config
 * @ClassName: RabbitMQTopicConfig
 * @Author: lyx
 * @CreateTime: 2021/4/8 13:12
 * @Description: RabbitMQ Topic模式的配置文件
 */

@Configuration
public class RabbitMQTopicConfig {

    private static final String QUEUE = "seckillQueue";

    private static final String EXCHANGE = "seckillExchange";

    @Bean
    public Queue queue() {
        return new Queue(QUEUE);
    }

    @Bean
    public TopicExchange topicExchange() {
        return new TopicExchange(EXCHANGE);
    }

    @Bean
    public Binding binding() {
        return BindingBuilder.bind(queue()).to(topicExchange()).with("seckill.#");
    }
}
